#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

const int N = 1e3 + 10;
int a[N];
int ans;
int count2(int x) {
	ans = 0;
	for (int i = 0; x >> i > 0; ++i) {
		int trp = x >> i & 1;
		if (trp == 1)
			ans++;
	}

	return ans;
}

void solve() {
	int n,m;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	cin >> m;
	for (int j = 1; j <= m; ++j) {
		for (int i = 1; i <= n; ++i) {
			a[i] = a[i] * count2(a[i]);
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << a[i] << " ";
	}

	return;
}

typedef long long ll;
const int M = 1e4 + 10;
string b[M];
bool cmp(string  a, string b) {
	
	string trp1 = a + b;
	string trp2 = b + a;
	for (int i = 0; i < trp1.size(); ++i) {
		if (trp1[i] - '0' == trp2[i] - '0')
			continue;
		if (trp1[i] - '0' > trp2[i] - '0')
			return true;
		if (trp1[i] - '0' < trp2[i] - '0')
			break;
	}
	return false;
}

string erjinzhi(int x) {
	string s = "";
	while (x > 0) {
		int temp1 = x % 2;
		s.push_back(temp1 + '0');
		x /= 2;
	}
	reverse(s.begin(), s.end());


	return s;
}

int c[M];
ll final_ans;
string result;
void solve1() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		b[i] = erjinzhi(i);
	}
	sort(b + 1, b + n + 1, cmp);
	for (int i = 1; i <= n; ++i) {
		result+=b[i];
	}

	
	for (int i = result.size() - 1; i >= 0; --i) {
		if (result[i] == '1')
			final_ans = final_ans + (1LL << (result.size() - i - 1));
	}
	cout << final_ans << endl;
	

	/*
	for (int i = result.size() - 1; i >= 0; --i) {
		ll tempp = 0;
		if (result[i] == '1')
			tempp = 1 << (result.size() - i - 1);
		else
			continue;
		int trp;
		for (int j = 0; tempp > 0; ++j) {
			c[j] = c[j] + tempp;
			trp = (c[j + 1] + c[j] / 10) / 10;
			c[j + 1] = c[j + 1] + c[j] / 10;
			c[j] = c[j] % 10;
			tempp /= 10;
		}		
	}
	*/
	// 将二进制字符串转换为十进制
	for (int i = result.size() - 1; i >= 0; --i) {
		if (result[i] == '1') {
			long long tempp = 1LL << (result.size() - i - 1); // 计算当前位的权重
			// 将 tempp 加到 c 中
			for (int j = 0; tempp > 0; ++j) {
				c[j] += tempp % 10;
				tempp /= 10;
				// 处理进位
				if (c[j] >= 10) {
					c[j + 1] += c[j] / 10;
					c[j] %= 10;
				}
			}
		}
	}
	// 找到最高非零位
	int nnn = M - 1;
	while (nnn > 0 && c[nnn] == 0) {
		--nnn;
	}

	
	for (int i = nnn; i >= 0; --i) {
		cout << c[i];
	}
	
	return;
}




int main() {

	//solve();
	solve1();

	return 0;
}